#!/bin/bash
###
 # @Author: yoola youlikesoilove@qq.com
 # @Date: 2025-01-10 23:32:41
 # @LastEditors: yoola youlikesoilove@qq.com
 # @LastEditTime: 2025-01-11 00:14:21
 # @FilePath: \CrabSystemProject\service_center\service_manager.sh
 # @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
### 

# 定义管理服务的函数
function manageService() {
    echo $1" Crab_CapturePhotoApp.service ..."
    sudo systemctl "$1" Crab_CapturePhotoApp.service
    echo $1" upload_node.service ..."
    sudo systemctl "$1" upload_node.service
    echo $1" main_node.service ..."
    sudo systemctl "$1" main_node.service
}

# 检查参数个数
if [ "$#" -lt 1 ]; then
    echo "Usage: $0 start|stop|restart"
    exit 1
fi

# 判断参数值并调用函数
if [[ "$1" == "start" || "$1" == "stop" || "$1" == "restart" ]]; then
    manageService "$1"
else
    echo "Usage: $0 start|stop|restart"
    exit 1
fi